package Model.Util;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import Model.Bean.PhoneType;
import Model.DbAccess.DbConnection;

public class PhoneTypeModel {
	DbConnection db = new DbConnection();
	
	/*
	 * Show All Phone Type
	 */
	public List<PhoneType> ShowAllType(){
		List<PhoneType> phoneTypes = new ArrayList<PhoneType>();
		String sql = "SELECT * FROM tbPhoneType";
		db.makeConnection();
		PhoneType phoneType;
		try{
			ResultSet rs = db.executeQuery(sql);
			while(rs.next()) {
				phoneType = new PhoneType();
				phoneType.setTypeID(rs.getInt("TypeID"));
				phoneType.setTypeName(rs.getString("TypeName"));
				phoneType.setSort(rs.getInt("Sort"));
				phoneTypes.add(phoneType);
			}
		}catch(SQLException ex){
			ex.printStackTrace();
		}finally{
			db.closeConnection();
			
		}
		return phoneTypes;
	}
}
